﻿@using ENail.Portal.Web.Models
@using Microsoft.Web.Mvc
@using MvcContrib.UI.Grid
@model AssignmentViewModel

@{
    ViewBag.Title = "Assignments";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div id="content">
    @using (Html.BeginForm<ENail.Portal.Web.Controllers.AssignmentController>(x=>x.Update(Model.RegistrationId, null), FormMethod.Post, null))
    {
    <table>
        <tr>
            <td>@Html.SubmitButton("Save")</td>
        </tr>
    </table>

    <table>
        <tr>
            <td>
                @Html.ValidationSummary()
            </td>
        </tr>
        <tr>
            <td>Employee:</td>
            <td>@Html.DropDownListFor(x => x.EmployeeId,
                                    new SelectList(Model.Employees, 
                                                    "Id", 
                                                    "EmployeeName"),
                                    "-Select Employee-")
            </td>
        </tr>
        <tr>
            <td>Nail Service:</td>
            <td>@Html.DropDownListFor(x => x.NailServiceId,
                                    new SelectList(Model.NailServices, 
                                                    "Id", 
                                                    "ServiceName"),
                                    "-Select Service-")
            </td>
        </tr>        
    </table>
    <table>
        <tr>
            <td>
                @Html.Grid(Model.Assignments).Columns((column) =>
                                                {
                                                    column.For(x => x.EmployeeName)
                                                            .Named("Employee")
                                                            .Attributes(width => "200px");
                                                    column.For(x => x.ServiceName)
                                                            .Named("Service")
                                                            .Attributes(width => "150px");
                                                }
                                        ).Attributes(@class => "grid"
                                        ).HeaderRowAttributes(new Dictionary<string, object> { { "class", "gridheaderrow" } }
                                        ).RowAttributes(row => new Dictionary<string, object> { { "onclick", "document.location='" + Url.Action("Update", new { Id = row.Item.Id }) + "'"} })
            </td>
        </tr>
    </table>
    }
</div>
